/*
 * Copyright 2008 Carnegie Mellon University
 * Licensed under the Apache License, Version 2.0 (the "License"); 
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *  
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, 
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
package edu.cmu.lti.sepia.task.setup;

import org.junit.Assert;

import edu.cmu.lti.sepia.data.db.SQL;
import edu.cmu.lti.sepia.data.resource.ResourceManager;

/**
 * This test case is disabled.
 * 
 * TODO: use onmemory mysql db for test
 * 
 * @author hideki
 *
 */
public class SetUpExperiment {

	private static SQL sql;
	private static String projectName = "test";
	
	/**
	 * @throws java.lang.Exception
	 */
//	@BeforeClass
	public static void setUp() throws Exception {
		ResourceManager.dbHost = "example.com";
		ResourceManager.dbPort = "3306";//Integer.parseInt( portnumber );
		ResourceManager.dbUser = "";
		ResourceManager.dbPass = "";
		ResourceManager.p = new java.util.Properties();
		ResourceManager.p.setProperty("db_prefix", "sepia_"+projectName+"_");
		sql = new SQL();
	}

	/**
	 * @throws java.lang.Exception
	 */
//	@AfterClass
	public static void tearDown() throws Exception {
		sql.close();
	}

//	@Test
	public void testSetupProject() {
		String batchResult = SetUp.setupProject( sql, projectName, "admin" );
		boolean batchSucceeded = batchResult.indexOf("Exception")==-1;
		boolean hostNotFound = batchResult.indexOf("UnknownHostException")!=-1;
		boolean accessDenied = batchResult.indexOf("Access denied")!=-1;
		if (!batchSucceeded) {
		  System.err.println(batchResult);
		}
		Assert.assertTrue(batchSucceeded);
		Assert.assertTrue(! hostNotFound);
		Assert.assertTrue(! accessDenied);
	}
	
}
